package com.wyk.controller;

import com.netflix.discovery.converters.Auto;
import com.wyk.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author WangYuKai
 * @Date 2022/6/23
 * @apiNote
 */
@RestController
@Slf4j
public class PaymentController {
    //注入service层
    @Autowired
    private PaymentService paymentService;
    @Value("${server.port}")
    private String serverPort;


    //返回端口号
    @GetMapping("/payment/hystrix/{id}")
    public String paymentOk(@PathVariable("id") Integer id){
        String result =  paymentService.paymentOk(id);
        log.info("****result:" + result);
        return result;
    }

    @GetMapping("/payment/hystrix/timeout/{id}")
    public String paymentError(@PathVariable("id") Integer id){
        String result =  paymentService.paymentError(id);
        log.info("****result:" + result);
        return result;
    }
    //服务熔断
    @GetMapping("/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id) {
        String result = paymentService.paymentCircuitBreaker(id);
        log.info("****result: " + result);
        return result;
    }

}
